package com.example.controller;

import com.aliyuncs.exceptions.ClientException;
import com.example.pojo.Result;
import com.example.utils.AliyunOssUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Slf4j
public class UploadController {
    @Autowired
    private AliyunOssUtils aliyunOssUtils;
    @PostMapping("/upload")
    public Result upload(MultipartFile image) throws  IOException {
        log.info("成功传入文件流,尝试开始上传,参数:{}",image);
        System.out.println("dev的摸鱼计划~");
        String url = aliyunOssUtils.upload(image);
        return Result.succeed(url);
    }
}
